<template>
  <div>
    <el-table :data="getmycalendar" style="width: 100%" max-height="250">
      <el-table-column prop="ID" label="上课时间" width="200">
        <template slot-scope="scope">{{totime(scope.row.starttime)}} {{scope.row.schoolclasstime}}</template>
      </el-table-column>
      <el-table-column prop="clazzname" label="班级名称"></el-table-column>
      <el-table-column prop="username" label="教师"></el-table-column>
      <el-table-column prop="type" label="状态"></el-table-column>
      <el-table-column prop="hour" label="已用课时"></el-table-column>
      <el-table-column prop="info" label="课程内容"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "mycurriculum",
  props: {
    student: {
      type: Object,
      default: () => {
        return {
          ID: "",
          accessToken: null,
          birthday: "",
          createdAt: null,
          deleted: null,
          headimg: "",
          lastlogintime: null,
          name: "",
          password: "",
          phonenum: null,
          publicopenid: null,
          relationship: "",
          schooladdressid: null,
          sex: "",
          smallopenid: null,
          type: "",
          unionid: null,
          updatedAt: null,
          schoolclazzstudentcalendar: [],
          schoolannouncementpushstudent: [],
          schoolstudenthomework: [],
          schoolstudentschoolclazz: []
        };
      }
    },
    totime: {
      type: Function,
      default: () => ""
    },
    getstudentnum: {
      type: Function,
      default: () => 0
    }
  },
  computed: {
    ...mapGetters([
      "getschoolclazz",
      "getschooluser",
      "getschooladdress",
      "getschoolcourse"
    ]),
    getmycalendar() {
      const { getschooluser, getschoolclazz, student } = this;
      const { schoolclazzstudentcalendar } = student;
      return schoolclazzstudentcalendar.map(v => {
        const {
          schoolclazzid,
          starttime,
          info,
          schoolclasstime
        } = v.schoolclazzschedule;
        const schooluser = getschooluser.find(vo => vo.ID == v.uid);
        let username = "";
        if (schooluser) {
          username = schooluser.name;
        }
        const { name: clazzname } = getschoolclazz.find(
          vo => vo.ID == schoolclazzid
        );
        return {
          ...v,
          username,
          clazzname,
          starttime,
          schoolclasstime,
          info
        };
      });
    }
  }
};
</script>